package com.ruoyi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ParkingRecordOut;
import com.ruoyi.service.IParkingRecordOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆出场记录Controller
 * 
 * @author dongdong
 * @date 2025-08-23
 */
@RestController
@RequestMapping("/parking/recordOut")
public class ParkingRecordOutController extends BaseController
{
    @Autowired
    private IParkingRecordOutService parkingRecordOutService;

    /**
     * 查询车辆出场记录列表
     */
    @PreAuthorize("@ss.hasPermi('parking:recordOut:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkingRecordOut parkingRecordOut)
    {
        startPage();
        List<ParkingRecordOut> list = parkingRecordOutService.selectParkingRecordOutList(parkingRecordOut);
        return getDataTable(list);
    }

    /**
     * 导出车辆出场记录列表
     */
    @PreAuthorize("@ss.hasPermi('parking:recordOut:export')")
    @Log(title = "车辆出场记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkingRecordOut parkingRecordOut)
    {
        List<ParkingRecordOut> list = parkingRecordOutService.selectParkingRecordOutList(parkingRecordOut);
        ExcelUtil<ParkingRecordOut> util = new ExcelUtil<ParkingRecordOut>(ParkingRecordOut.class);
        util.exportExcel(response, list, "车辆出场记录数据");
    }

    /**
     * 获取车辆出场记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('parking:recordOut:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(parkingRecordOutService.selectParkingRecordOutById(id));
    }

    /**
     * 新增车辆出场记录
     */
    @PreAuthorize("@ss.hasPermi('parking:recordOut:add')")
    @Log(title = "车辆出场记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkingRecordOut parkingRecordOut)
    {
        return toAjax(parkingRecordOutService.insertParkingRecordOut(parkingRecordOut));
    }

    /**
     * 修改车辆出场记录
     */
    @PreAuthorize("@ss.hasPermi('parking:recordOut:edit')")
    @Log(title = "车辆出场记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkingRecordOut parkingRecordOut)
    {
        return toAjax(parkingRecordOutService.updateParkingRecordOut(parkingRecordOut));
    }

    /**
     * 删除车辆出场记录
     */
    @PreAuthorize("@ss.hasPermi('parking:recordOut:remove')")
    @Log(title = "车辆出场记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(parkingRecordOutService.deleteParkingRecordOutByIds(ids));
    }

}
